<?php 


header("Content-type: text/html; charset=utf-8") ;


function C($config = null)
{
	$configs = include './config/config.php';


	if(is_array($config)){
		$temp = array();

		foreach ($config as $v) {
			 $temp[$v] = $configs[$v];
		}
		return $temp;
	}

	if($config==null){
		return $configs;
	}elseif(!isset($configs[$config])){
		return '不存在';
	}else{
		return $configs[$config];
	}
	
}


///引错误信息模板
function error($url, $msg)
{
	include './Tpl/error.html';
	exit;
}

function success($url,$msg){
	include './Tpl/success.html';
}

function delsuccess($url,$msg){
	include './Tpl/delsuccess.html';
}

function editsuccess($url,$msg){
	include './Tpl/editsuccess.html';
}


//转单位
function F($num)
{
	if($num>pow(1024,3)){
		echo round($num/pow(1024,3),2)."GB";
	}elseif($num>pow(1024,2)){
		echo round($num/pow(1024,2),2)."MB";
	}elseif($num>pow(1024,1)){
		echo round($num/pow(1024,1),2)."kB";
	}else{
		echo $num."kB";
	}
}

//删除文件夹
function DelDir($dirPath)
{
	$dirPath = rtrim($dirPath,'/');

	$pathArr = glob($dirPath."/*");

	if(!$pathArr){
		rmdir($dirPath);
	}else{

		foreach ($pathArr as $v) {
			if(is_dir($v)){
				// echo "dir".$v;
				DelDir($v);
			}else{
				unlink($v);
				// echo "unlink".$v;
			}
		}

		rmdir($dirPath);

	}
}



function showimg($url){
	$suffix=substr($url,strrpos($url, '.'));
	switch ($suffix) {
		case '.jpg':
			return $url;
			break;
		case '.png':
			return $url;
			break;
		case '.txt':
			return './Upload/txt.jpg';
			break;
		case '.php':
		return './Upload/txt.jpg';
		break;
		default:
			return './Upload/moren.jpeg';
			break;
	}
}






 ?>